package com.yhd.tomcat.handler;

import com.yhd.tomcat.service.BaseService;

import java.net.Socket;
import java.util.Map;
import java.util.concurrent.*;

/**
 * @author yhd
 * @email yinhuidong1@xiaomi.com
 * @description TODO
 * @since 2021/6/10 下午4:22
 */
public abstract class Handler {
    /**
     * servlet容器
     */
    protected  static Map<String, BaseService> servletMap ;

    /**
     * TODO 这里可以考虑读取配置文件获取，动态修改
     */
    protected static final Integer PORT = 8080;

    /**
     * 处理请求的线程池
     */
    protected static final ThreadPoolExecutor executor=new ThreadPoolExecutor(5,10,60, TimeUnit.SECONDS,new ArrayBlockingQueue<>(1));
    /**
     * Session
     */
    protected static Map<String,Map<String,String>> SESSION = new ConcurrentHashMap<>();

    /**
     * 异步任务+ 阻塞队列 ，当接收到请求的时候，进行消息转发处理
     */
    protected static  ArrayBlockingQueue<Socket> EVENTQUEUE = new ArrayBlockingQueue<>(100);
}
